#include <iostream>
#include "Stack.h"
#include "Queue.h"

using namespace std;
using namespace STACK;
using namespace QUEUE;

int main() {
    string pandromeStr;
    bool isPandrome;
    char isContinue;
    
    while(true) {
        isPandrome=true;
        cout << "Enter pandrome:";
        cin >> pandromeStr;
        int len=pandromeStr.length();
        PSTACK pS = create_stack();
        PQUEUE pQ = create_queue();
        
        for(int i=0; i<len; ++i) {
            char val = pandromeStr[i];
//            cout << "val:" << val << endl;
            push_stack(pS, val);
            en_queue(pQ, val);
        }
        
//        traverse_stack(pS);
//        traverse_queue(pQ);
        while(is_stack_empty(pS)!=true && is_queue_empty(pQ)!=true) {
            char x;
            char y;
            pop_stack(pS, &x);
            de_queue(pQ, &y);
            if(x!=y) {
                isPandrome = false;
            }
//            cout << "x:" << x << endl;
//            cout << "y:" << y << endl;
        }
        
        if(isPandrome) {
            cout << "TRUE Pandrome" << endl;
        } else {
            cout << "FALSE Pandrome" << endl;
        }
        
        clear_stack(pS);
        destroy_queue(pQ);
        
        cout << "continue:Y/N:";
        cin >> isContinue;
        if(toupper(isContinue)!='Y') {
            cout << "退出成功" << endl;
            break;
        }
    }
}
